Skip to content

Fix <SaveButton> is not enabled when the form is prefilled (from <CloneButton> for instance)#10765

Merged
slax57 merged 2 commits intomasterfrom
fix-save-button-not-enabled-when-form-prefilled
Jun 5, 2025
Merged

Fix <SaveButton> is not enabled when the form is prefilled (from <CloneButton> for instance)#10765
slax57 merged 2 commits intomasterfrom
fix-save-button-not-enabled-when-form-prefilled

Conversation

@djhi
Copy link
Copy Markdown
Contributor

@djhi djhi commented Jun 2, 2025

Problem

When users navigate to a page with a form prefilled from the router location, e.g. they clicked a <CloneButton>, the <SaveButton> is disabled by default because the form isn't dirty yet.

Fixes #9217.

Solution

As react-hook-form does not provide a way to set the form values from an object while setting the form dirty, we made the <SaveButton> check for the presence of a record in the router location too.

How To Test

  • Run the simple example
  • Click any post
  • Click the Clone button
  • Check that all save buttons are enabled

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

Also, please make sure to read the contributing guidelines.

@djhi djhi added the RFR Ready For Review label Jun 2, 2025
@slax57 slax57 self-requested a review June 3, 2025 13:42
@slax57 slax57 added this to the 5.8.4 milestone Jun 5, 2025
@slax57 slax57 merged commit c529941 into master Jun 5, 2025
15 checks passed
@slax57 slax57 deleted the fix-save-button-not-enabled-when-form-prefilled branch June 5, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save button is disabled on form when using the clone button

2 participants